﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


//using SH_VBoxLibrary;

namespace SH_VBoxVM_Service.Classes
{

    public interface IVBoxGreatManager
    {


        /// <summary>
        /// Starts all VMs in the List of the Config File.
        /// </summary>
        void startEngine();


        /// <summary>
        /// Stops all VMs in the List of the Config File.
        /// </summary>
        void stopEngine();
    }

    /// <summary>
    /// Class controls an Dictionary of all VM's created at init time.
    /// Determines a lot of the Service options according to the Configuration File.
    /// </summary>
    public class VBoxGreatManager : IVBoxGreatManager
    {
        /// <summary>
        /// All VMS they are not to be touched.
        /// These are loaded by the ConfigIO Class from the 
        /// SH_VBoxLibrary
        /// </summary>
        private List<string> vms = new List<string>();

        IVBoxCom vboxcom = null;

        public VBoxGreatManager()
        {
            vboxcom = new VBoxCom();
            vms = ConfigIO.VmList;
        }

        public void startEngine()
        {
            for (int i = 0; i < vms.Count; i++)
            {
                vboxcom.StartVM(vms[i]);
            }
        }

 
        public void stopEngine()
        {
            for (int i = 0; i < vms.Count; i++)
            {
                vboxcom.ShutdownVM(vms[i]);
            }
            
            //@deprecated : See Method Comments for more info.
            //ApplicationLoader.UnfreezeThreads();
        }

    }
}
